luci-base-ucode: add initial ucode based LuCI runtime
authorJo-Philipp Wich <[email protected]>
Mon, 29 Aug 2022 15:09:22 +0000 (17:09 +0200)
committerJo-Philipp Wich <[email protected]>
Mon, 24 Oct 2022 23:03:37 +0000 (01:03 +0200)
commitded8ccf93ec5163be35c41501869110e5dab30d1
tree7802274633e7936d9cb6f7a5ce7914a748bd0913
parentf2133059e1d6695e6a1b572ae6aded9d7dd3db35
luci-base-ucode: add initial ucode based LuCI runtime

This commits introduces an initial ucode based LuCI runtime. It supports
JSON menu files as used by Lua based LuCI and the template, call, view and
alias dispatch targets.

It is able to render a basic LuCI installation without errors. An embedded
Lua VM is lazily loaded when Lua based resources are encountered, such as
`*.htm` templates or server side Lua call targets.

When a template is requested, the ucode runtime first tries to render an
`/usr/share/ucode/luci/template/${path}.uc` ucode template and falls back
to rendering the corresponding `/usr/lib/lua/luci/view/${path}.htm` Lua
template in case no suitable ucode replacement is found. This allows for
gradual migration of existing Lua based tmeplates to ucode.

Furthermore, a set of stripped down LuCI libraries is shipped in the
`/usr/lib/lua/luci/ucodebridge/` directory. Those libraries provide
compatibility shims for the current Lua API towards Lua templates and Lua
based server side actions while utilizing the ucode request runtime state
internally.

Signed-off-by: Jo-Philipp Wich <[email protected]>
30 files changed:
modules/luci-base-ucode/Makefile [new file with mode: 0644]
modules/luci-base-ucode/htdocs/cgi-bin/luci-ucode [new file with mode: 0755]
modules/luci-base-ucode/luasrc/ucodebridge/luci/dispatcher.lua [new file with mode: 0644]
modules/luci-base-ucode/luasrc/ucodebridge/luci/http.lua [new file with mode: 0644]
modules/luci-base-ucode/luasrc/ucodebridge/luci/template.lua [new file with mode: 0644]
modules/luci-base-ucode/luasrc/ucodebridge/luci/ucodebridge.lua [new file with mode: 0644]
modules/luci-base-ucode/luasrc/ucodebridge/luci/util.lua [new file with mode: 0644]
modules/luci-base-ucode/root/usr/share/rpcd/ucode/luci [new file with mode: 0644]
modules/luci-base-ucode/src/Makefile [new file with mode: 0644]
modules/luci-base-ucode/src/contrib/lemon.c [new file with mode: 0644]
modules/luci-base-ucode/src/contrib/lempar.c [new file with mode: 0644]
modules/luci-base-ucode/src/lib/lmo.c [new file with mode: 0644]
modules/luci-base-ucode/src/lib/lmo.h [new file with mode: 0644]
modules/luci-base-ucode/src/lib/luci.c [new file with mode: 0644]
modules/luci-base-ucode/src/lib/plural_formula.y [new file with mode: 0644]
modules/luci-base-ucode/ucode/controller/admin/index.uc [new file with mode: 0644]
modules/luci-base-ucode/ucode/controller/admin/uci.uc [new file with mode: 0644]
modules/luci-base-ucode/ucode/dispatcher.uc [new file with mode: 0644]
modules/luci-base-ucode/ucode/http.uc [new file with mode: 0644]
modules/luci-base-ucode/ucode/runtime.uc [new file with mode: 0644]
modules/luci-base-ucode/ucode/sys.uc [new file with mode: 0644]
modules/luci-base-ucode/ucode/template/csrftoken.ut [new file with mode: 0644]
modules/luci-base-ucode/ucode/template/error404.ut [new file with mode: 0644]
modules/luci-base-ucode/ucode/template/error500.ut [new file with mode: 0644]
modules/luci-base-ucode/ucode/template/footer.ut [new file with mode: 0644]
modules/luci-base-ucode/ucode/template/header.ut [new file with mode: 0644]
modules/luci-base-ucode/ucode/template/sysauth.ut [new file with mode: 0644]
modules/luci-base-ucode/ucode/template/view.ut [new file with mode: 0644]
modules/luci-base-ucode/ucode/uhttpd.uc [new file with mode: 0644]
modules/luci-base-ucode/ucode/zoneinfo.uc [new file with mode: 0644]